<?php

function batchaddpage($batchnum,$qqnumber,$qqpassword,$cookieuser,$qqnum){
$batchnums=$batchnum+1;
print <<<EOT
					<div id="pages-batchadd-main">
						<h3>还有<span class="batchadd-num">$batchnums</span>个QQ等待添加……</h3>
						<hr>
						<div class="batchadd-qqnumber">
						<p>正在为您添加号码为:<span class="batchadd-num">$qqnumber</span></p>
						<a href="">跳过此号码</a>
						</div>
EOT;

echo '<p>挂Q提示:<span class="batchadd-num">';

echo batch_add($batchnum,$qqnumber,$qqpassword,$cookieuser,$qqnum,qidcz(),fuwuqirand());

echo '</span></p></div>';

}


function batch_add($batchnum,$qqnumber,$qqpassword,$cookieuser,$qqnum,$qid,$fwq){
$out=addqq($qqnumber,$qqpassword);

$mysqlqq = mysql_query("SELECT * FROM xige_qqlist WHERE email='$cookieuser' and qq='$qqnumber'");
$sqlqq = mysql_fetch_array($mysqlqq);

if($qqnumber==$sqlqq['qq']){
echo "此Q已列表,请勿重复!";
if ($batchnum>=0){
$_SESSION["BatchQQnum"]=$batchnum;
}
}elseif(preg_match("/您输入的账号不存在/",$out)){
echo "腾讯提示:QQ账号不存在";
if ($batchnum>=0){
$_SESSION["BatchQQnum"]=$batchnum;
}
}elseif(preg_match("/操作异常/",$out)){
$a=explode('请输入上图字符(不区分大小写)：',$out);
$outt=$a[0];
$b=$a[1];
$img=explode('src="',$outt);
$img=explode('" alt="',$img[1]);
$rt=explode('name="r" value="',$out);
$rw=explode('"/>',$rt[1]);
$extendt=explode('name="extend" value="',$out);
$extendw=explode('"/>',$extendt[1]);
$r_sidt=explode('name="r_sid" value="',$out);
$r_sidw=explode('"/>',$r_sidt[1]);
$login_urlt=explode('name="login_url" value="',$out);
$login_urlw=explode('"/>',$login_urlt[1]);
$sidt=explode('name="sid" value="',$out);
$sidw=explode('"/>',$sidt[1]);
$ipt=explode('name="rip" value="',$out);
$ipw=explode('"/>',$ipt[1]);
$hidpwt=explode('name="hexpwd" value="',$out);
$hidpww=explode('"/>',$hidpwt[1]);
echo '<form action="" method="post">';
echo '输入QQ验证码:';
echo '<div id="addqqyes-left">';
echo '<img src="'.$img[0].'" width="100px">';
echo '<input type="hidden" name="qq" value="'.$qqnumber.'"/>';
echo '<input type="hidden" name="mima" value="'.$qqpassword.'"/>';
echo '<input type="hidden" name="r" value="'.$rw[0].'"/>';
echo '<input type="hidden" name="extend" value="'.$extendw[0].'"/>';
echo '<input type="hidden" name="r_sid" value="'.$r_sidw[0].'"/>';
echo '<input type="hidden" name="login_url" value="'.$login_urlw[0].'"/>';
echo '<input type="hidden" name="sid" value="'.$sidw[0].'"/>';
echo '<input type="hidden" name="ip" value="'.$ipw[0].'">';
echo '<input type="hidden" name="hidpw" value="'.$hidpww[0].'">';
echo '</div>';
echo '<div id="addqqyes-right">';
echo '<input type="text" name="verify" value="">';
echo '</div>';
echo '<div id="addqqyes-button">';
echo '<input type="submit" name="yzm" value="马上登录">';
echo '</div>';
echo '</form>';
}elseif(preg_match("/暂时无法登录/",$out)){
echo '您的帐号暂时无法登录，请到<a href="http://aq.qq.com/007" target="_blank">http://aq.qq.com/007</a>恢复正常使用。';
if ($batchnum>=0){
$_SESSION["BatchQQnum"]=$batchnum;
}
}elseif(preg_match("/密码不正确/",$out)){
echo '腾讯提示:密码不正确';
if ($batchnum>=0){
$_SESSION["BatchQQnum"]=$batchnum;
}
}elseif(preg_match("/系统繁忙/",$out)){
echo "腾讯提示:系统繁忙";
if ($batchnum>=0){
$_SESSION["BatchQQnum"]=$batchnum;
}
}elseif(preg_match("/登录3GQQ成功/",$out)){
$out=explode('sid=',$out);
$sid=substr($out[1],0,24);
$time=time();
$qqnum=$qqnum+1;

mysql_query("INSERT INTO xige_qqlist (id,fwq,qid,email,qq,qqol,mima,sid,sidol,adddate) VALUES ('','$fwq','$qid','$cookieuser','$qqnumber','0','$qqpassword','$sid','0','$time')");
mysql_query("INSERT INTO xige_".$fwq." (id,qid,email,qq,mima,sid,adddate,emailtime) VALUES ('','$qid','$cookieuser','$qqnumber','$qqpassword','$sid','$time','0')");

mysql_query("Update xige_info set qqnum='$qqnum' where email='$cookieuser'");

file_get_contents("http://ti.3g.qq.com/g/s?sid=" . $sid . "&r=" . $qqnumber. "&aid=arelate&ac=42&tu=weibiantai&bid=h%23QQGenius%230%230%230%2316");
echo "小伙伴!记录添加成功啦!";
if ($batchnum>=0){
$_SESSION["BatchQQnum"]=$batchnum;
}
}else{
echo "未知错误!请联系管理员";
if ($batchnum>=0){
$_SESSION["BatchQQnum"]=$batchnum;
}
}
}
?>